package com.wc.alorithm_blue_bridge._二分.Q4860;

import java.util.*;
import java.io.*;

/**
 * @Author congege
 * @Description 基德的神秘冒险
 * https://www.lanqiao.cn/problems/4860/learning/?page=1&first_category_id=1
 * @Date Created in 2023/11/25-15:15
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long q = sc.nextInt();
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        long[] dp = new long[n];
        // 判断位置
        for (long i = n - 1, j = 0; j < n - 2; i--, j++) {
            dp[(int) j] = i * (i - 1) / 2;
        }
        // 前缀和
        for (int i = 1; i < n; i++) {
            dp[i] += dp[i - 1];
        }

        // 二分查找
        while (q-- > 0) {
            int left = 0;
            int right = n - 3;
            int mid;
            long k = sc.nextLong();
            while (left <= right) {
                mid = left + (right - left) / 2;
                if (dp[mid] >= k) {
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            System.out.println(array[left]);
        }

    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (Exception e) {
                return -1;
            }
            return (int) in.nval;
        }
    }
}
